create database SuperSurvey
go
use SuperSurvey
go
create table UserLogin(
	UserName nvarchar(50) primary key ,
	[Password] nvarchar(50),
	[Status] nvarchar(50),
	TimeOnline datetime,
	TimeOffline datetime,
	IP nvarchar(50)
)
go
create table UserInformation(
	UserName nvarchar(50) primary key references UserLogin(UserName),	
	FullName nvarchar(50),
	BirthDate datetime,
	Email nvarchar(50),
	Phone nvarchar(50),
	[Address] nvarchar(50)
)
go

create table Survey_Category(
	CategoryID nvarchar(50) primary key,
	CategoryName nvarchar(50),
	[Description] nvarchar(50)
)
go
create table Question(
	QuestionID nvarchar(50) primary key,
	CategoryID nvarchar(50) foreign key references Survey_Category(CategoryID),
	QuestionContent nvarchar(50)
)
go
create table Answer(
	AnswerID nvarchar(50) primary key,
	QuestionID nvarchar(50) foreign key references Question(QuestionID),
	AnswerContent nvarchar(50)
)
go
create table Survey(
	SurveyID nvarchar(50) primary key,
	CategoryID nvarchar(50) foreign key references Survey_Category(CategoryID),
	QuestionID nvarchar(50) references Question(QuestionID),
	UserName nvarchar(50) references UserInformation(UserName),
	SurveyName nvarchar(50),
	TimeCreate nvarchar(50),
	TimeExpire nvarchar(50),
	[Description] nvarchar(50)
)
go
create table Result(
	ResultID nvarchar(50) primary key,
	SurveyID nvarchar(50) foreign key references Survey(SurveyID),
	TotalAnswer int
)
go
